{extend name="public:layout" /}

{block name="title"}
	<title>{:site('siteName')}-充值审核</title>
{/block}

{block name="css"}
	<link rel="stylesheet" type="text/css" href="__STATIC__/{$theme}/css/user.css">
{/block}

{block name="content"}
	<div class="layui-main">
		<div class="user-main">
			<div class="user-left">
				{include file="public:user" /}
			</div>
			<div class="user-right">
				<div class="layui-tab layui-tab-brief">
					<ul class="layui-tab-title">
						<li class="layui-this">充值审核</li>
					</ul>
					<div class="layui-tab-content">
						<table class="table">
						    <thead>
						        <tr>
						            <th>会员ID</th>
						            <th>用户名</th>
						            <th>充值数量</th>
						            <th>说明</th>
						            <th>状态</th>
						            <th>创建时间</th>
						            <th>操作</th>
						        </tr>
						    </thead>
						    <tbody>
								{volist name="list" id="v"}
						        <tr>
									<td>{$v.user_id}</td>
									<td>{$v.username}</td>
									<td>{$v.num}</td>
									<td>{$v.explain}</td>
									<td>
										{eq name="v.status" value="-1"}充值失败{/eq}
										{eq name="v.status" value="0"}待支付{/eq}
										{eq name="v.status" value="1"}已支付{/eq}
										{eq name="v.status" value="2"}充值成功{/eq}
									</td>
									<td>{:date('Y-m-d H:i',$v['create_time'])}</td>
									<td>
										{if $v['status'] == 0 || $v['status'] == 1}
											<button data-rid="{$v.id}" class="layui-btn layui-btn-mini layui-btn-main confirm-success">成功</button>
											<button data-rid="{$v.id}" class="layui-btn layui-btn-mini layui-btn-danger confirm-fail">失败</button>
										{/if}
									</td>
						        </tr>
								{/volist}
						    </tbody>
						</table>
						<div class="page">
							{$list->render()}
						</div>
					</div>
				</div> 
			</div>
		</div>
	</div>
{/block}

{block name="script"}
	<script type="text/javascript">
		layui.use(['form', 'layer'], function(){
			var $ = layui.jquery;
    		var layer = layui.layer;

    		$(".confirm-success").click(function() {
    			var rid = $(this).data('rid');
    			layer.confirm('审核成功，{$currency}即时到账，确认。', {
		            btn: ['确认', '取消'],
		            icon: 3
		        }, function(index) {
		        	$.post('{:url("index/agent/confirm")}', {id: rid,status:'2'}, function(res) {
		            	if(res.status == 1){
		            		layer.msg(res.msg, {
			                    time: 1000
			                }, function() {
			                    location.reload();
			                });
		            	}else{
		            		layer.msg(res.msg);
		            	}
		            },'json');
		            layer.close(index);
		        });
		        return false;
		    });

		    $(".confirm-fail").click(function() {
    			var rid = $(this).data('rid');
    			layer.prompt({
				  	title: '请输入失败原因',
				}, function(value, index, elem){
				  	$.post('{:url("index/agent/confirm")}', {id: rid,status:'-1',explain:value}, function(res) {
		            	if(res.status == 1){
		            		layer.msg(res.msg, {
			                    time: 1000
			                }, function() {
			                    location.reload();
			                });
		            	}else{
		            		layer.msg(res.msg);
		            	}
		            },'json');
		            layer.close(index);
				});
		        return false;
		    });

		});
	</script>
{/block}